home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / utilit~1 / gdb35src.zoo / dist-gdb / wait.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-05  |  1.7 KB  |  56 lines

  1.  
  2. /* Define how to access the structure that the wait system call stores.
  3.    On many systems, there is a structure defined for this.
  4.    But on vanilla-ish USG systems there is not.  */
  5.  
  6. #ifndef atarist
  7.  
  8. #ifndef HAVE_WAIT_STRUCT
  9. #define WAITTYPE int
  10. #define WIFSTOPPED(w) (((w)&0377) == 0177)
  11. #define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0)
  12. #define WIFEXITED(w) (((w)&0377) == 0)
  13. #define WRETCODE(w) ((w) >> 8)
  14. #define WSTOPSIG(w) ((w) >> 8)
  15. #define WCOREDUMP(w) (((w)&0200) != 0)
  16. #define WTERMSIG(w) ((w) & 0177)
  17. #define WSETEXIT(w, status) ((w) = (status))
  18. #define WSETSTOP(w,sig)  ((w) = (0177 | ((sig) << 8)))
  19. #else
  20. #include <sys/wait.h>
  21. #define WAITTYPE union wait
  22. #define WRETCODE(w) (w).w_retcode
  23. #define WSTOPSIG(w) (w).w_stopsig
  24. #define WCOREDUMP(w) (w).w_coredump
  25. #define WTERMSIG(w) (w).w_termsig
  26. #define WSETEXIT(w, status) ((w).w_status = (status))
  27. #define WSETSTOP(w,sig)  \
  28.   ((w).w_stopsig = (sig), (w).w_coredump = 0, (w).w_termsig = 0177)
  29. #endif
  30.  
  31. #else /* atarist */
  32. /* Again we are different: I don't trust the libraries' wait, so I
  33.     use my own... (It's placed in atariwait.c and should overwrite
  34.     the libraries' symbol) */
  35.  
  36. #define WAITTYPE int
  37.  
  38. #define WIFEXITED(x)    ((int)((x) & 0xFF00) == 0)
  39. #define WEXITSTATUS(x)    ((int)((x) & 0xFF))
  40.  
  41. #define WIFSIGNALED(x)    (((int)((x) & 0xFF00) > 0) && ((int)(((x) & 0xFF) == 0)))
  42. #define WTERMSIG(x)    ((int)(((x) & 0xFF00) >> 8))
  43.  
  44. #define WIFSTOPPED(x)    (((int)((x) & 0xFF) == 0x7F) && ((int)(((x) >> 8) & 0xFF) != 0))
  45. #define WSTOPSIG(x)    ((int)(((x) >> 8) & 0xFF))
  46.  
  47. #define WRETCODE(w) WTERMSIG(w)
  48.  
  49. /* the following defines are used by remote.c, dunno how to emulate them */
  50. #define WSETEXIT(w, status) 
  51. #define WSETSTOP(w,sig)  
  52.  
  53. int wait(int *x);
  54.  
  55. #endif
  56.